<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>两个变量交换值</title>
  </head>
  <body>
    <script>
      // 交换前
      var temp; // 临时变量
      var a = 10;
      var b = true;
      console.log('交换前：' + a, b);

      // 交换
      temp = a;
      a = b;
      b = temp;

      console.log('交换后：' + a, b);
    </script>
  </body>
</html>
